<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use DB;
use Session;

class _InterfaceServer extends Controller {
	
	const SERVER_DOMAIN = 'https://portal.dr-r.cn:8080/';

	/**
	 * 数组信息返回json
     */
    protected function getDataJson($state=1,$message='',$data='')
    {
        $jsonData = [
             'status'  => $state,
             'msg' => $message,
             'data' => $data,
        ];
        return json_encode($jsonData);
	}

	/**
	 * 错误提示
	 *
	 * @return string[]
	 */
	protected function jsonStatus1000($msg) {
		return json_encode([ 
				'data' => [],
				'msg' => $msg,
				'status' => 0 
		]);
	}
	
	/**
	 * 校验地址栏是否传参
	 *
	 * @param string $param        	
	 */
	protected function paramVerifyExist($param) {
		$param = explode ( ',', $param );
		foreach ( $param as $item ){
			if (! isset ( $_REQUEST [$item] )){
				return $item;
			}
		}	
		return '';
	}
	
	/**
	 * 校验地址栏传参
	 *
	 * @param string $param        	
	 */
	protected function paramVerifyEmpty($param) {
		$param = explode ( ',', $param );
		foreach ( $param as $item )
			if ($_REQUEST [$item] == '')
				return $item;
		return '';
	}
	
	/*X-YUN-KEY   6df0499bef7f152c29b602c4ba7ce991
	X-YUN-ID    03774ad7979a5909e78f9c9db3a2f0b2*/
    /**
     *  验证头信息
     */
    protected function verifykey($yun_key,$yun_id) {
    	if ($yun_key != '6df0499bef7f152c29b602c4ba7ce991' || $yun_id != '03774ad7979a5909e78f9c9db3a2f0b2') {
    		return '非法请求';
    	}else{
    		return '777';
    	}
    }

}